<?php
/**
 * @version		$Id: example.php 9764 2007-12-30 07:48:11Z ircmaxell $
 * @package		Joomla
 * @subpackage	Content
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die();

jimport( 'joomla.plugin.plugin' );

/**
 * Example Content Plugin
 *
 * @package		Joomla
 * @subpackage	Content
 * @since 		1.5
 */
class plgContentStatZone_BowlingStats extends JPlugin
{

	/**
	 * Constructor
	 *
	 * For php4 compatability we must not use the __constructor as a constructor for plugins
	 * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
	 * This causes problems with cross-referencing necessary for the observer design pattern.
	 *
	 * @param object $subject The object to observe
	 * @param object $params  The object that holds the plugin parameters
	 * @since 1.5
	 */
	function plgContentStatZone_BowlingStats( &$subject, $params )
	{
		parent::__construct( $subject, $params );
        
        // load plugin parameters
        $this->_plugin = JPluginHelper::getPlugin( 'Content', 'StatZone_BowlingStats' );
        $this->_params = new JParameter( $this->_plugin->params );
        
        
}

	/**
	 * PlayerClub prepare content method
	 *
	 * Method is called by the view
	 *
	 * @param 	object		The article object.  Note $article->text is also available
	 * @param 	object		The article params
	 * @param 	int			The 'page' number
	 */
     function onPrepareContent( &$article, &$params, $limitstart )
	 {
        global $mainframe;
        $id = $article->id;
        
              
        // expression to search for
        $regex = '/{StatZoneBowlingStats}/i';
        
         // checking
		if ( !preg_match($regex, $article->text)  ) {
			return;
		}
        
        $db =& JFactory::getDBO();
        
        //Stats are shown by getting the current season and prev seasons
        //Then they are grouped by Team and by Game type (1 or 2 dayers)
        
        
        //1. lets first start by getting the team ids of this player (can b >1) and the playerid from the contentid
        //Union all teams this player has played for, could be for different clubs (cant use statzone_teamplayers since it only stores current team)
        $sql ='SELECT DISTINCT t.id as id, t.name, p.firstname, p.surname, p.id as playerid
              FROM #__statzone_players AS p 
              INNER JOIN  #__statzone_bowlingscores bowlsc ON p.id = bowlsc.playerid
              INNER JOIN #__statzone_teams AS t ON t.id = bowlsc.teamid
              WHERE p.contentid =  '. $id;
              
        $db->setQuery( $sql );
        if (!$db->query())
		{
			echo JError::raiseWarning( 500, $db->getErrorMsg() );
            $article->text = preg_replace( $regex, '', $article->text );
            return;
		}
        
        $teamids = $db->loadObjectList();
        
        $playerid = $teamids[0]->playerid; //the player id will be the same for all rows returned- it better be
        
        //2. Get a list of all distinct seasons for this player AND its published
        $sql ='SELECT DISTINCT sc.season AS season '
        .'  FROM #__statzone_scorecards AS sc '
        .'  INNER JOIN jos_statzone_bowlingscores AS bs ON bs.scorecardid = sc.id'
        .'  INNER JOIN jos_statzone_players AS p ON p.id = bs.playerid'
        .'  WHERE p.contentid = ' . $id
        .'  AND sc.published = 1'
        ;
        $db->setQuery( $sql );
        if (!$db->query())
		{
			echo JError::raiseWarning( 500, $db->getErrorMsg() );
            $article->text = preg_replace( $regex, '', $article->text );
            return;
		}
        $seasons = $db->loadObjectList();
        
        //3. What is the current season:
        $currentSeason = '';
        $currentDateMonth = date('m');
        $currentDateYear = date('Y');
        if($currentDateMonth < 7) //before july
        {
            $currentSeason = ($currentDateYear - 1) . '/' . $currentDateYear ; //2007/2008
        }
        else
        {
            $currentSeason = $currentDateYear . '/' . ($currentDateYear + 1); //2008/2009
        }
        
        if(count($seasons) == 0)
        {
            //no seasons played...say so and return
            $article->text = preg_replace( $regex, 'No bowling stats recorded yet.', $article->text );
            return;
        }
        
                        
        //_____Get the current seasons stats_____
        $currentseason_data = '';
        foreach($seasons as $seasonrow)
        {
            //if the season is = current season then dont put it in a slide
            if(trim($seasonrow->season) == trim($currentSeason))
            {
                //$testBool = trim($seasonrow->season) == trim($currentSeason);
                //prep the div where all the current seasons bowling stats are going into
                $currentseason_div = '<div><h3>Bowling stats current season: ' . $currentSeason.'</h3>{seasonsbowlingstats_current}</div>';
                
                //group the stats by teams played for:
                $currentseason_stats='';
                
                //get 1 day games first
                foreach($teamids as $teamrecord)           
                {
                    $teamname_playingfor = $teamrecord->name;
                    $teamid = $teamrecord->id;
                    $currentseason_stats = $currentseason_stats . plgContentStatZone_BowlingStats::getStatsTableForPlayerInTeam($teamid , $playerid, $teamname_playingfor, true,$seasonrow->season);
                }
                //now get 2 day games
                foreach($teamids as $teamrecord)           
                {
                    $teamname_playingfor = $teamrecord->name;
                    $teamid = $teamrecord->id;
                    $currentseason_stats = $currentseason_stats . plgContentStatZone_BowlingStats::getStatsTableForPlayerInTeam($teamid , $playerid, $teamname_playingfor, false,$seasonrow->season);
                }
                
                //merge the div with the data
                $currentseason_data = preg_replace( '/{seasonsbowlingstats_current}/i', $currentseason_stats, $currentseason_div);
            }
        }
        
        //____Get the previous seasons stats_______
        $prevseason_data = '';
        $prevseason_stats  = '';
        foreach($seasons as $seasonrow)
        {
            if($seasonrow->season != $currentSeason)
            {
                               
                //prep the div where all the Prev seasons bowling stats are going into
                $prevseason_div = ''. $seasonrow->season .'{seasonsbowlingstats_prev}';
                
                //group the stats by teams played for:
                //1 dayes first
                foreach($teamids as $teamrecord)           
                {
                    $teamname_playingfor = $teamrecord->name;
                    $teamid = $teamrecord->id;
                    $prevseason_stats = $prevseason_stats  . plgContentStatZone_BowlingStats::getStatsTableForPlayerInTeam($teamid , $playerid, $teamname_playingfor, true,$seasonrow->season);
                }
                
                //then 2 dayers
                foreach($teamids as $teamrecord)           
                {
                    $teamname_playingfor = $teamrecord->name;
                    $teamid = $teamrecord->id;
                    $prevseason_stats = $prevseason_stats  . plgContentStatZone_BowlingStats::getStatsTableForPlayerInTeam($teamid , $playerid, $teamname_playingfor, false,$seasonrow->season);
                }
                //merge the div with the data
                $prevseason_div = preg_replace( '/{seasonsbowlingstats_prev}/i', $prevseason_stats, $prevseason_div);
            }
        }
        
        if($prevseason_stats > '')
        {
            $prevseason_data = '{slide=Bowling stats prior seasons}'.$prevseason_div.'{/slide}';
        }   
        
        //join all the stats html
        $html = $currentseason_data .'<br>'. $prevseason_data;
        
        //render
        $article->text = preg_replace( $regex, $html, $article->text );
    
    }
    
	/*function onPrepareContent_old( &$article, &$params, $limitstart )
	{
		global $mainframe;
        $id = $article->id;
        
        // expression to search for
        $regex = '/{StatZoneBowlingStats}/i';
        
        $db =& JFactory::getDBO();
        
         // checking
		if ( !preg_match($regex, $article->text)  ) {
			return;
		}
        
        //grouping all stats by seasons, teams
        
        //lets first start by getting the team ids of this player (can b >1)
        $sql ='SELECT t.id, t.name, p.firstname, p.surname'
        .'  FROM #__statzone_playerteams AS pt '
        .'  INNER JOIN jos_statzone_players AS p ON p.id = pt.playerid'
        .'  INNER JOIN jos_statzone_teams AS t ON t.id = pt.teamid'
        .'  WHERE p.contentid = ' . $id
        ;
        $db->setQuery( $sql );
        if (!$db->query())
		{
			echo JError::raiseWarning( 500, $db->getErrorMsg() );
            $article->text = preg_replace( $regex, '', $article->text );
            return;
		}
        $teamids = $db->loadObjectList();
        
        //get all of the seasons
        $sql ='SELECT DISTINCT sc.season AS season '
        .'  FROM #__statzone_scorecards AS sc '
        .'  INNER JOIN jos_statzone_bowlingscores AS bs ON bs.scorecardid = sc.id'
        .'  INNER JOIN jos_statzone_players AS p ON p.id = bs.playerid'
        .'  WHERE p.contentid = ' . $id
        .'  AND sc.published = 1'
        ;
        $db->setQuery( $sql );
        if (!$db->query())
		{
			echo JError::raiseWarning( 500, $db->getErrorMsg() );
            $article->text = preg_replace( $regex, '', $article->text );
            return;
		}
        $seasons = $db->loadObjectList();
        
        $seasondivs = '';
        $statsrowshtml = '';
        foreach($seasons as $seasonrow)
        {
            $seasondivs = $seasondivs . '<div id=season_' . $seasonrow->season .'  >Season '. $seasonrow->season.': {seasonsbowlingstats}</div>';
            
            //foreach season get the bowling stats for this player
            $sql ='SELECT DISTINCT sc.id AS id,bs.teamid, playerteam.name as playerteamname, hometeam.name as hometeamname, '
                                .' awayteam.name as awayteamname, sc.teamidhome, sc.teamidaway, sc.firstinndate, sc.secondinndate, '
                                .' bs.overs, bs.runs, bs.wickets, bs.inningsno, bs.maidens'
                  .' FROM jos_statzone_scorecards AS sc '
                  .' INNER JOIN jos_statzone_bowlingscores AS bs ON bs.scorecardid = sc.id'
                  .' INNER JOIN jos_statzone_players AS p ON p.id = bs.playerid'
                  .' INNER JOIN jos_statzone_teams AS hometeam ON hometeam.id = sc.teamidhome'
                  .' INNER JOIN jos_statzone_teams AS awayteam ON awayteam.id = sc.teamidaway'
                  .' INNER JOIN jos_statzone_teams AS playerteam ON playerteam.id = bs.teamid'
                  .' WHERE p.contentid = ' . $id
                  .' AND sc.published = 1'
                  .' ORDER BY sc.firstinndate, sc.secondinndate DESC'
                  ;
                $db->setQuery( $sql );
                if (!$db->query())
                {
                    echo $sql;//JError::raiseWarning( 500, $db->getErrorMsg() );
                    $article->text = preg_replace( $regex, '', $article->text );
                    return;
                }
                $stats = $db->loadObjectList();
                
                $i = 0;
                foreach($stats as $statsrows)
                {
                    
                    $statsrows->runs = $statsrows->runs;
                    $statsrows->apponent = $statsrows->teamid == $statsrows->teamidhome ? $statsrows->awayteamname : $statsrows->hometeamname;
                    $statsrows->homeaway = $statsrows->teamid == $statsrows->teamidhome ? 'Home' : 'Away';
                    $statsrows->inndate = $statsrows->inningsno == 1 ? $statsrows->firstinndate : $statsrows->secondinndate;
                    $statsrows->econ = $statsrows->runs / $statsrows->overs;
                    
                    $rowentryclass = ($i % 2 == 0) ? 'sectiontableentry1' : 'sectiontableentry2';
                    
                    $statsrowshtml = $statsrowshtml
                                .'<tr class="'.$rowentryclass.'">'
                                    .'<td width="30"  >'. $statsrows->inndate .'</td>'
                                    .'<td width="30"  nowrap="true">'.$statsrows->playerteamname.  '</td>'
                                    .'<td width="30"  nowrap="true">'.$statsrows->apponent.  '</td>'
                                    .'<td width="20" >'.$statsrows->overs. '</td>'
                                    .'<td width="20" >'.$statsrows->maidens. '</td>'
                                    .'<td width="20" >'.$statsrows->runs.  '</td>'
                                    .'<td width="20" >'.$statsrows->wickets.  '</td>'
                                    .'<td width="20" >'.number_format($statsrows->econ,2) .'</td>'
                                    .'<td width="20" >'.$statsrows->homeaway.  '</td>'
                                .'</tr>';
                                
                    $i++;
                }//ends for each innings
        } //ends for each season

        $statstable = ''
                    .'<table width="100%" border="0" cellspacing="0" cellpadding="0">'
                    .'<thead>'
                        .'<tr>'
                            .'<th width="30" nowrap="true" class="sectiontableheader">Date</th>'
                            .'<th width="30" nowrap="true" class="sectiontableheader">Playing for</th>'
                            .'<th width="30" nowrap="true" class="sectiontableheader">Against</th>'
                            .'<th width="20" nowrap="true" class="sectiontableheader">Overs</th>'
                            .'<th width="20" nowrap="true" class="sectiontableheader">Maidens</th>'
                            .'<th width="20" nowrap="true" class="sectiontableheader">Runs</th>'
                            .'<th width="20" nowrap="true" class="sectiontableheader">Wickets</th>'
                            .'<th width="20" nowrap="true" class="sectiontableheader">Econ</th>'
                            .'<th width="20" nowrap="true" class="sectiontableheader">Home/Away</th>'
                        .'</tr>'
                    .'</thead>'
                    .'<tbody>'
                    . $statsrowshtml
                    .'</tbody>'
                    .'</table>'
        ;
        
        $html = preg_replace( '/{seasonsbowlingstats}/i', $statstable, $seasondivs );
              
        // replace the tag with the replacement text
        $article->text = preg_replace( $regex, $html, $article->text );
        
	}*/
    
    
    /**
	 * Gets a fully formatted html table with the stats data given the params
	 *
	 */
	function getStatsTableForPlayerInTeam( &$teamid , &$playerid, &$teamname_playingfor, $oneDayers, &$season)
	{
        $db =& JFactory::getDBO();
        $regex = '/{StatZoneBowlingStats}/i';
        
        $statstable = '';
        $gameType = $oneDayers ? "1" : "2";
        
        if($oneDayers)
        {
            $sql ='SELECT DISTINCT sc.id AS id,sc.teamidhome as teamid, playerteam.name as playerteamname, '
                                .' sc.teamidhome, sc.teamidopponent, sc.firstinndate, sc.secondinndate, sc.innings AS inningscount,opponentteam.name as opponent,'
                                .' bs1.overs, bs1.maidens, bs1.runs, bs1.wickets, bs1.inningsno '
                  .' FROM #__statzone_scorecards AS sc '
                  .' INNER JOIN #__statzone_bowlingscores AS bs1 ON bs1.scorecardid = sc.id AND bs1.inningsno = 1 AND bs1.playerid = ' . $playerid
                  .' INNER JOIN #__statzone_teams AS playerteam ON playerteam.id = sc.teamidhome'
                  .' INNER JOIN #__statzone_teams AS opponentteam ON opponentteam.id = sc.teamidopponent'
                  .' WHERE sc.teamidhome = ' . $teamid
                  .' AND sc.published = 1'
                  .' AND sc.innings = 1'
                  .' AND sc.season = \'' . $season . '\''
                  .' AND bs1.id is not null';
        }
        else
        {
             $sql ='SELECT DISTINCT sc.id AS id,sc.teamidhome as teamid, playerteam.name as playerteamname, '
                                .' sc.teamidhome, sc.teamidopponent, sc.firstinndate, sc.secondinndate, sc.innings AS inningscount, opponentteam.name as opponent,'
                                .' bs1.overs, bs1.maidens, bs1.runs, bs1.wickets, bs1.inningsno, bs1.id as bs1id,'
                                .' bs2.overs as overs2, bs2.maidens as maidens2, bs2.runs as runs2, bs2.wickets as wickets2, bs2.inningsno as inningsno2, bs2.id as bs2id'
                  .' FROM #__statzone_scorecards AS sc '
                  .' LEFT JOIN #__statzone_bowlingscores AS bs1 ON bs1.scorecardid = sc.id AND bs1.inningsno = 1 AND bs1.playerid = ' . $playerid
                  .' LEFT JOIN #__statzone_bowlingscores AS bs2 ON bs2.scorecardid = sc.id AND bs2.inningsno = 2 AND bs2.playerid = ' . $playerid
                  .' INNER JOIN #__statzone_teams AS playerteam ON playerteam.id = sc.teamidhome'
                  .' INNER JOIN #__statzone_teams AS opponentteam ON opponentteam.id = sc.teamidopponent'
                  .' WHERE sc.teamidhome = ' . $teamid
                  .' AND sc.published = 1'
                  .' AND sc.innings = 2'
                  .' AND sc.season = \'' . $season . '\''
                  ;
                  
            //echo '<br><br>'.$sql;
        }
         
       
         
        $sql .=' ORDER BY sc.firstinndate DESC';
        
        //echo '<br>'.$sql;
        $db->setQuery( $sql );
        if (!$db->query())
        {
            echo '<br><br>ERROR:' . $sql;//JError::raiseWarning( 500, $db->getErrorMsg() );
            $article->text = preg_replace( $regex, 'ERRRROR', $article->text );
            return;
        }
        $stats = $db->loadObjectList();
                
        if(count($stats) == 0) 
        {
            //no stats for this team
            $statstable = ''
             .'<table width="100%" border="0" cellspacing="0" cellpadding="0">'
                    .'<thead>'
                        .'<tr>'
                         .'<td width="100"  nowrap="true">No bowling stats for '.$teamname_playingfor.'</td>'
                        .'</tr>'
                    .'</thead>'
            .'</table>'
            ;
            
            return '';
        } 
        
        //lets prebuild the table cos we know there is stats for this player in this team
        $statstable = ''
                    .'<table width="100%" border="0" cellspacing="0" cellpadding="0">'
                    .'<thead>'
                        .'<tr><td colspan=10><h4>'.$teamname_playingfor.' ('.$gameType.' day games)</h4></td></tr>'
                        .'<tr>'
                            .'<th width="10%" nowrap="true" class="sectiontableheader">Date</th>'
                            .'<th width="40%" nowrap="true" class="sectiontableheader">Opponent</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">Inn</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">Ovrs</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">Mdns</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">Runs</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">Wkts</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">5W</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">Eco</th>'
                            .'<th width="5%" nowrap="true" class="sectiontableheader">Ave</th>'
                        .'</tr>'
                    .'</thead>'
                    .'<tbody>'
                    .'<tr class="sectiontableentry2">{statssummary}</tr>'
                    . '{statsrowshtml}'
                    .'</tbody>'
                    .'</table>'
         ;           
        $i = 0;
        $statsrowshtml = '';
        $summary_innCount = 0;
        $summary_overs = 0;
        $summary_maidens = 0;
        $summary_runs = 0;
        $summary_wickets = 0;
        $summary_fifers = 0;
        $summary_econ = 0;
        $summary_ave = 0;
        $summary_gamecount = 0;
                
        foreach($stats as $statsrows)
        {
            //$statsrows->runs = $statsrows->notout ? $statsrows->runs.'*' : $statsrows->runs;
            //$statsrows->apponent = $statsrows->teamid == $statsrows->teamidhome ? $statsrows->awayteamname : $statsrows->hometeamname;
            //$statsrows->homeaway = $statsrows->teamid == $statsrows->teamidhome ? 'Home' : 'Away';
            $statsrows->inndate = $statsrows->inningsno == 1 ? $statsrows->firstinndate : $statsrows->secondinndate;
            $statsrows->inndate = date('Y-m-d',strtotime($statsrows->inndate)); //format it
            
            if($statsrows->inningscount == 2 & ($statsrows->bs1id == null & $statsrows->bs2id == null))
            {
                //no stats so skip this record
                continue;
            }
            
            $summary_gamecount+=1;
            $totalruns = $statsrows->runs + $statsrows->runs2;
            $totalwickets = $statsrows->wickets + $statsrows->wickets2;
            $totalovers = $statsrows->overs + $statsrows->overs2;
            $totalmaidens = ($statsrows->maidens + $statsrows->maidens2);
            $average = 0;
            $economy = 0;
            
            //calc 5wkts hauls
            $fifers = 0;
            
            if($statsrows->wickets >= 5)
            { 
                $fifers++ ;
            }
            if($statsrows->wickets2 >= 5)
            { 
                $fifers++ ;
            }
            
            //calc average
            if( $totalwickets == 0)
            {
                $average = 'N/A';
            }
            else
            {
                $average = $totalruns / ($totalwickets);
            }
            
            //calc economy
            if( $totalruns == 0)
            {
                $economy = 0;
            }
            else
            {
                $economy = $totalruns / ($totalovers);
            }
            
            $rowentryclass = ($i % 2 == 0) ? 'sectiontableentry1' : 'sectiontableentry2';
            
            $statsrowshtml = $statsrowshtml
                        .'<tr class="'.$rowentryclass.'">'
                            .'<td >'. $statsrows->inndate .'</td>'
                            .'<td nowrap="true">'.$statsrows->opponent.  '</td>'
                            .'<td >'. $statsrows->inningscount . '</td>'
                            .'<td >'. $totalovers . '</td>'
                            .'<td >'. $totalmaidens . '</td>'
                            .'<td >'. $totalruns .'</td>'
                            .'<td >'. $totalwickets.'</td>'
                            .'<td >'. $fifers .'</td>' 
                            .'<td >'. number_format($economy,2).'</td>' 
                            .'<td >'. number_format($average,2) .'</td>' 
                        .'</tr>';
            
            //add to summary
            $summary_innCount += $statsrows->inningscount;
            $summary_overs +=  $totalovers;
            $summary_maidens +=  $totalmaidens;
            $summary_runs += $totalruns;
            $summary_wickets += $totalwickets;
            $summary_fifers += $fifers;
                       
            $i++;
        }

        if($summary_gamecount==0)
        {
            return '';        
        }
        
        //create the summary row
        $summary_ave = 0;
        if($summary_wickets == 0)
        {
            $summary_ave = '-';
        }
        else
        {
            $summary_ave = $summary_runs / ($summary_wickets);
        }
        
        $summary_economy=0;
        if($summary_overs == 0)
        {
            $summary_economy = '-';
        
        }
        else
        {
            $summary_economy = ($summary_runs / $summary_overs );
        }
        
        $summaryrowhtml = ''
        .'<td colspan=2>All '.$summary_gamecount.' games</td>'
        .'<td>'.$summary_innCount.'</td>'
        .'<td>'.$summary_overs.'</td>'
        .'<td>'.$summary_maidens.'</td>'
        .'<td>'.$summary_runs.'</td>'
        .'<td>'.$summary_wickets .'</td>'
        .'<td>'.$summary_fifers.'</td>'
        .'<td>'.number_format($summary_economy,2).'</td>'
        .'<td>'.number_format($summary_ave,2).'</td>'
        ;
        
        //now insert the stats rows into the prebuilt table
        $statstable = preg_replace( '/{statsrowshtml}/i', $statsrowshtml, $statstable );
        $statstable = preg_replace( '/{statssummary}/i', $summaryrowhtml, $statstable );
        return $statstable;
    }
    
	/**
	 * Example after display title method
	 *
	 * Method is called by the view and the results are imploded and displayed in a placeholder
	 *
	 * @param 	object		The article object.  Note $article->text is also available
	 * @param 	object		The article params
	 * @param 	int			The 'page' number
	 * @return	string
	 */
	function onAfterDisplayTitle( &$article, &$params, $limitstart )
	{
		global $mainframe;

		return 'werasdfdasf';
	}

	/**
	 * Example before display content method
	 *
	 * Method is called by the view and the results are imploded and displayed in a placeholder
	 *
	 * @param 	object		The article object.  Note $article->text is also available
	 * @param 	object		The article params
	 * @param 	int			The 'page' number
	 * @return	string
	 */
	function onBeforeDisplayContent( &$article, &$params, $limitstart )
	{
		global $mainframe;
        
        return '';
	}

	/**
	 * Example after display content method
	 *
	 * Method is called by the view and the results are imploded and displayed in a placeholder
	 *
	 * @param 	object		The article object.  Note $article->text is also available
	 * @param 	object		The article params
	 * @param 	int			The 'page' number
	 * @return	string
	 */
	function onAfterDisplayContent( &$article, &$params, $limitstart )
	{
		global $mainframe;
        $id 	= $row->id;
	    $html 	= '';
       
		return $html;
	}
}
